|
![](/i/fill.gif) |
"ingo" <ing### [at] home nl> wrote in message
news:Xns### [at] povray org...
> in news:3b77cd84@news.povray.org Gail Shaw wrote:
>
> > // very pseudo-code
> >
> > #declare ObjectsArray=array[4] {Object1,Object2,Object3,Object4}
> > #declare ProbArray = array[4] {0.5,0.2,0.2,0.1}
> >
> > Pile(ObjectsArray,ProbArray)
> >
> > In the above case 50% of the pile will be object1, 20% object2 etc
> >
> >
>
> You'll have to do it in a few steps:
>
I've got the probability part. The way I've done it (which is probably not
the best)
is to create a second probability array. Using the above example the second
array would read {0.5,0.7,0.9,0.1}
I generate a random number between 0 and 1 then read along the array
checking
to see if the random number is smaller than the array value. If it is I use
the
array index as an index into the object array and stop checking, otherwise I
increment the
array index.
The problem I have is if one of the objects is created using a macro then
the macro is evaluated
when the object is assigned to the ObjectsArray and I'd like to find a way
to only evaluate the
macro when the object is actually created in the scene.
Gail
--
*************************************************************************
* gsh### [at] monotix co za * Step into the abyss, *
* http://www.rucus.ru.ac.za/~gail/ * and let go. Babylon 5 *
*************************************************************************
* The difficult we do immediately, the impossible takes a little longer *
*************************************************************************
Post a reply to this message
|
![](/i/fill.gif) |